import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class ScreeningHall {
    // static part
    private static final Map<String, int[]> seatCounts = new HashMap<>();
    static { //加载影厅参数
        try (BufferedReader reader = new BufferedReader(new FileReader("影厅参数.txt"))) {
            String line;
            while ((line = reader.readLine()) != null) { //每读一行循环一次
                String[] parts = line.split(" ");
                seatCounts.put(parts[0], new int[] { //key: [0]type, [1]row, [2]column, [3]serviceFee
                        Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3])});
            }
        } catch (IOException e) {
            e.fillInStackTrace();
        }
    }

    //target part

    private final String type;
    private final ArrayList<ArrayList<Boolean>> seatChart; // 座位布尔表(动态大小) -- true: 已选  false: 可选
    private final int serviceFee; // 服务费 -- 不同档次的影厅服务费不同

    public ScreeningHall(String type) {
        this.type = type;
        ArrayList<Boolean> tempRow = new ArrayList<>();

        this.seatChart = new ArrayList<>();
        for (int i = 0; i<seatCounts.get(type)[1]; i++) //设置列数
            tempRow.add(false);
        for (int i = 0; i<seatCounts.get(type)[0]; i++) //设置行数
            this.seatChart.add(tempRow);
        this.serviceFee = seatCounts.get(type)[2];
    }

    public int getCapacity() {
        return seatChart.size() + seatChart.getFirst().size();
    }

    // getter
    public String getType() {
        return type;
    }

    public int getServiceFee() {
        return serviceFee;
    }

    public int getRows() { return seatChart.size(); }
    public int getColumns() { return seatChart.getFirst().size(); }
}
